import { RouteRecordRaw } from "vue-router";
import UserAdmin from "@/views/admin_view/UserAdmin.vue";
import Test from "@/views/Test.vue";
import ACCESS_ENUM from "@/access/accessEnum";
import NoAuth from "@/views/NoAuth.vue";
import UserLayout from "@/layouts/UserLayout.vue";
import UserLoginView from "@/views/UserLoginView.vue";
import UserRegisterView from "@/views/UserRegisterView.vue";
import AppAdmin from "@/views/admin_view/AppAdmin.vue";
import QuestionAdmin from "@/views/admin_view/QuestionAdmin.vue";
import Home from "@/views/Home.vue";
import ScoringResultAdmin from "@/views/admin_view/ScoringResultAdmin.vue";
import AppDetailPage from "@/views/app/AppDetailPage.vue";
import AddAppPage from "@/views/add/AddAppPage.vue";
import AddQuestionPage from "@/views/add/AddQuestionPage.vue";
import AddScoringResultPage from "@/views/add/AddScoringResultPage.vue";
import DoAnswerPage from "@/views/answer/DoAnswerPage.vue";
import QuestionListViesw from "@/views/QuestionListViesw.vue";
import AnswerResultPage from "@/views/answer/AnswerResultPage.vue";
import MyAnswerPage from "@/views/answer/MyAnswerPage.vue";
import AdminUserAnswerPage from "@/views/admin_view/AdminUserAnswerPage.vue";

export const routes: Array<RouteRecordRaw> = [
  {
    path: "/",
    name: "首页",
    component: Home,
  },

  {
    path: "/app/detail/:id",
    name: "应用详情页",
    props: true,
    component: AppDetailPage,
    meta: {
      hide: true,
    },
  },

  {
    path: "/app/questionList/:id",
    name: "题目列表",
    props: true,
    component: QuestionListViesw,
    meta: {
      hide: true,
    },
  },

  {
    path: "/answer/do/:appId",
    name: "答题",
    component: DoAnswerPage,
    props: true,
    meta: {
      hide: true,
      access: ACCESS_ENUM.USER,
    },
  },
  {
    path: "/answer/result/:id",
    name: "答题结果",
    component: AnswerResultPage,
    props: true,
    meta: {
      hide: true,
      access: ACCESS_ENUM.USER,
    },
  },
  {
    path: "/answer/myresult",
    name: "答题记录",
    component: MyAnswerPage,
    props: true,
    meta: {
      hide: false,
      access: ACCESS_ENUM.USER,
    },
  },

  {
    path: "/add/app",
    name: "创建应用",
    props: true,
    component: AddAppPage,
  },

  {
    path: "/add/app/:id",
    name: "修改应用",
    props: true,
    component: AddAppPage,
    meta: {
      hide: true,
    },
  },
  {
    path: "/admin/user",
    name: "用户管理",
    component: UserAdmin,
    meta: {
      access: ACCESS_ENUM.ADMIN,
    },
  },
  {
    path: "/admin/app",
    name: "应用管理",
    component: AppAdmin,
    meta: {
      access: ACCESS_ENUM.ADMIN,
    },
  },

  {
    path: "/admin/Scoring",
    name: "题目答案管理",
    component: ScoringResultAdmin,
    meta: {
      access: ACCESS_ENUM.ADMIN,
    },
  },

  {
    path: "/admin/question",
    name: "题目管理",
    component: QuestionAdmin,
    meta: {
      access: ACCESS_ENUM.ADMIN,
    },
  },

  {
    path: "/add/question/:appId/:appName",
    name: "创建题目",
    component: AddQuestionPage,
    props: true,
    meta: {
      hide: true,
    },
  },
  {
    path: "/add/scoring_result/:appId",
    name: "创建评分",
    component: AddScoringResultPage,
    props: true,
    meta: {
      hide: true,
    },
  },
  {
    path: "/admin/user_answer",
    name: "回答管理",
    component: AdminUserAnswerPage,
    meta: {
      access: ACCESS_ENUM.ADMIN,
    },
  },
  {
    path: "/auth",
    name: "auth",
    component: NoAuth,
    meta: {
      hide: true,
    },
  },

  //登录用户
  {
    path: "/user",
    name: "用户",
    component: UserLayout,
    meta: {
      hide: true,
    },
    children: [
      {
        path: "/user/login",
        name: "登录",
        component: UserLoginView,
      },
      {
        path: "/user/register",
        name: "注册",
        component: UserRegisterView,
      },
    ],
  },
];
